class subjectTitle extends BaseScreen{
	public constructor() {
		super();
		this.skinName = "resource/eui_skins/subject_title.exml";
	}

	private lab_title:eui.Label;

	private lab_answer0:eui.Label;
	
	private lab_answer1:eui.Label;
	
	private lab_answer2:eui.Label;
	
	private lab_answer3:eui.Label;

	private rect_answer0:eui.Rect;
	private rect_answer1:eui.Rect;
	private rect_answer2:eui.Rect;
	private rect_answer3:eui.Rect;
	
	private c_answer0:eui.Image;
	private c_answer1:eui.Image;
	private c_answer2:eui.Image;
	private c_answer3:eui.Image;
	

	private result:string = '';

	//1选择   2判断
	private subject_tp:number = 1;

	private subject:Object;

	private answer_change:Object;

	public is_answer:boolean = false;

	public parent_page:gpage3;
	public set_info(infos:Object,ids:number,par:gpage3){
		this.subject = infos;

		this.lab_title.text = (ids+1)+'.'+this.subject['title'];

		if(this.subject['tp']==1){
			this.lab_answer0.text = this.subject['subject'][0];
			this.lab_answer1.text = this.subject['subject'][1];
			this.lab_answer2.text = this.subject['subject'][2];
			this.lab_answer3.text = this.subject['subject'][3];	
		}
		else if(this.subject['tp'] == 2){
			this.lab_answer0.text = "错误"
			this.lab_answer1.text = "正确";
			this['g_answer2'].visible = false;
			this['g_answer3'].visible = false;
		}
		

		this.parent_page = par;
		this.answer_change = {'A':0,'B':1,'C':2,'D':3};

		this.addEventListener(egret.TouchEvent.TOUCH_TAP,this.click_hander,this);
	}

	public click_hander(e:egret.TouchEvent){
		console.log(e.target.name);
		if(!e.target || this.is_answer || this.parent_page.game_state !=2)
			return;
		
		var target_name:string = e.target.name;
		if(!target_name)
			return;
			
		this.is_answer = true;
		console.log('target_name='+target_name);
		if(target_name == this.subject['answer']){
			this['c_answer'+this.answer_change[target_name]].source = RES.getRes('p3_ok_png');
			utils.CoreData.instance.cur_source+=10;
			utils.CoreData.instance.cur_Dtsource+=10;
		}
		else{
			this['c_answer'+this.answer_change[target_name]].source = RES.getRes('p3_fail_png');
		}

		this.parent_page.is_select_all();
	}

	public show_result(){
		this['c_answer'+this.answer_change[ this.subject['answer']]].source = RES.getRes('p3_ok_png');
	}

	
	
}